<template>
  <a-modal title="历史版本信息" :visible="visible" @cancel="cancel" :footer="null"  width="900px">
    <a-table :columns="columns" :data-source="dataList"  :pagination="false">
    <span slot="versionNumber" slot-scope="text,record">
           V{{text}}
        </span>
      <span slot="action" slot-scope="text, record">
        <a-button type="primary" @click="detailed(record)" size="small"> 查看详情 </a-button>
      </span>
    </a-table>
  </a-modal>
</template>
<script>
  import {getProgramHistoryList} from '@/api/technical/approval'
  const columns = [
    { title: '版本号', dataIndex: 'versionNumber',scopedSlots: { customRender: 'versionNumber' }},
    { title: '上传时间', dataIndex: 'fiDate' },
    { title: '操作', scopedSlots: { customRender: 'action' } }
  ]

  export default {
    props: {
      // 显隐控件
      visible: {
        type: Boolean,
        default() {
          return false
        }
      },
      versionId:{
        type:String,
        default(){
          return ''
        }
      },
      row: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    data() {
      return {
        dataList: [],
        columns
      }
    },
    watch: {
      visible: {
        immediate: true,
        handler(val) {
          if (val) {
            this.getProgramHistoryListFn();
          }
        }
      },
    },
    methods: {
      cancel() {
        this.$emit('cancel',false)
      },
      getProgramHistoryListFn(){
        getProgramHistoryList({id:this.versionId}).then((res)=>{
          this.dataList = res.data;
        })
      },
      //查看历史数据详情
      detailed(record) {
        this.$router.push({
          path: '/technical/ShiGroup/administrativeLedger/detail',
          query: {
            type: 'view',
            id: record.id,
            historicalData:true,
            confessAuditStatusId: this.row.confessAuditStatusId,
            reAuditId: this.row.id,
            replyId: this.row.id,
            conId: this.row.id,
            technologyStatusId: this.row.id,
            versionNumber: record.versionNumber
          }
        })
        this.$emit('cancel',false)
      },
    }
  }
</script>